package com.inspur.ourhis_afterend.Controller;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.inspur.ourhis_afterend.Service.PaymentDetailsServie;
import com.inspur.ourhis_afterend.Tools.PageAction;
import com.inspur.ourhis_afterend.Tools.Result;
import com.inspur.ourhis_afterend.model.PaymentDetails;
import com.inspur.ourhis_afterend.vo.PaymentDetailsVo;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("/paymentDetails")
public class PaymentDetailsController {

    @Resource(name = "paymentDetailService")
    PaymentDetailsServie paymentDetailsServie;

    @ApiOperation("缴费明细查询")
    @ApiParam(value = "会员id可空")
    @PostMapping("/search")
    public Result selectBySelective(@RequestBody PageAction pageAction,
                                    @RequestParam(value = "memberid",required = false)Integer memberid){
        IPage<PaymentDetailsVo> page = new Page<>(pageAction.getPageNo(),pageAction.getPageSize());
        return Result.success(paymentDetailsServie.SelectBySelective(page,memberid));
    }

    @ApiOperation("缴费明细插入")
    @ApiParam(value = "会员id可空")
    @PostMapping("/add")
    public Result add(@RequestBody PaymentDetails paymentDetails) throws Exception {
        System.out.println(paymentDetails);
        return Result.success(paymentDetailsServie.add(paymentDetails));
    }
}
